]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
backgroundMenu: Allow for long presses on touch devices
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 22 Jul 2014 10:34:56 +0000 (12:34 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 24 Jul 2014 16:15:02 +0000 (18:15 +0200)
These don't have a button set. Also, popup the menu relative to gesture
reported coordinates, and not relative to the pointer position everytime.

https://bugzilla.gnome.org/show_bug.cgi?id=733633

js/ui/backgroundMenu.js

index d9341f576df0a2c2550c7c98fb22fc8d0358a01e..446559f3e64ab602b7cd4f9747e9e12c818fed11 100644 (file)
@@ -33,8 +33,7 @@ function addBackgroundMenu(actor, layoutManager) {
     actor._backgroundManager = new PopupMenu.PopupMenuManager({ actor: actor });
     actor._backgroundManager.addMenu(actor._backgroundMenu);
 
-    function openMenu() {
-        let [x, y] = global.get_pointer();
+    function openMenu(x, y) {
         Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0);
         actor._backgroundMenu.open(BoxPointer.PopupAnimation.NONE);
     }
@@ -42,16 +41,21 @@ function addBackgroundMenu(actor, layoutManager) {
     let clickAction = new Clutter.ClickAction();
     clickAction.connect('long-press', function(action, actor, state) {
         if (state == Clutter.LongPressState.QUERY)
-            return action.get_button() == 1 && !actor._backgroundMenu.isOpen;
+            return ((action.get_button() == 0 ||
+                     action.get_button() == 1) &&
+                    !actor._backgroundMenu.isOpen);
         if (state == Clutter.LongPressState.ACTIVATE) {
-            openMenu();
+            let [x, y] = action.get_coords();
+            openMenu(x, y);
             actor._backgroundManager.ignoreRelease();
         }
         return true;
     });
     clickAction.connect('clicked', function(action) {
-        if (action.get_button() == 3)
-            openMenu();
+        if (action.get_button() == 3) {
+            let [x, y] = action.get_coords();
+            openMenu(x, y);
+        }
     });
     actor.add_action(clickAction);